const pool = require('../config/db');

// 记录操作日志
async function logOperation(
    userId, 
    action, 
    module, 
    description, 
    ipAddress = '', 
    userAgent = ''
) {
    try {
        await pool.execute(
            `INSERT INTO operation_logs 
            (user_id, action, module, description, ip_address, user_agent) 
            VALUES (?, ?, ?, ?, ?, ?)`,
            [userId, action, module, description, ipAddress, userAgent]
        );
    } catch (error) {
        console.error('记录操作日志错误:', error);
    }
}

module.exports = {
    logOperation
};
